<?php

namespace App\Http\Controllers\Web;


use Illuminate\Http\Response;
use App\Models\Article;
use App\Models\ArticleClass;
use Illuminate\Support\Facades\Auth;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;

class HelpController extends Controller
{

      /**
     * SetingController constructor.
     */
    public function __construct()
    {
        $this->articleClass = new ArticleClass();
    }
    
    public function index(Request $request)
    {
        $fullValue = $request->all(); //表单提交的所有内容
        $info = '';
        if(!empty($fullValue)){
            $id = $fullValue['artcile_id'];
            $info = Article::where(['article_id'=>$id])->first();
        }else{
             $cate = ArticleClass::get(); //查询所有分类
             $c = $cate[0]['class_id'];
             $info = Article::where(['article_class_id'=>$c])->first();
        }
        $cate = ArticleClass::get(); //查询所有分类
        //根据分类查询下面的文章
        foreach ($cate as $key=>$val){
          $catr_id = $val['class_id'];
          $art[] = Article::where(['article_class_id'=>$catr_id])->get();
        }
        return view('web.help.list',['cate'=>$cate,'art'=>$art,'info'=>$info]);
    }

}
